/**
 * Created with IntelliJ IDEA.
 * Description:
 * User:DELL
 * Date:2025-01-25
 * Time:23:52
 */
public class Demo7 {
    public static void main(String[] args) {
        Object object=new Object();
        Thread t1=new Thread(()->{
           synchronized (object){
               System.out.println("wait之前！");
               try {
                   object.wait();
               } catch (InterruptedException e) {
                   throw new RuntimeException(e);
               }
               System.out.println("wait之后！");
           }
        });
        Thread t2=new Thread(()->{
            try {
                Thread.sleep(5000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            synchronized (object){
                System.out.println("进行通知！");
                object.notify();
            }
        });
        t1.start();
        t2.start();
    }
}
